package com.example.demo.controller;
/**
 * @Author Justice
 * @Date 2019/4/8 16:17
 * @Version 1.0
 */

import com.example.demo.java.FirstClass;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.UUID;

@RestController
public class DbController {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @Autowired
    private RedissonClient redissonClient;

    @Autowired
    private FirstClass firstClass;

    @RequestMapping("/u")
    public String getDbType() {
        redisTemplate.opsForValue().set("key", "value");
        return "helloworld";
    }

    @RequestMapping("/a")
    public String getA() {
        return firstClass.sayHello();
    }

    @RequestMapping("/r")
    public String getR() {
        RLock lock = redissonClient.getLock(UUID.randomUUID().toString());
        String name = lock.getName();
        return name;


    }


}